//
//  ViewController.m
//  LT
//
//  Created by dllo on 16/5/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "RecommendViewController.h"
#import "registerViewController.h"




#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height


@interface ViewController ()



@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    
    self.navigationController.navigationBar.hidden = YES;
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    //新用户引导页
    
    self.scrollView = [[UIScrollView alloc]init];
    self.scrollView.frame = CGRectMake(0, 0, WIDTH , HEIGHT);
    self.scrollView.backgroundColor = [UIColor whiteColor];
    self.scrollView.contentSize = CGSizeMake(WIDTH *5, 0);
    [self.view addSubview:self.scrollView];
    
    for (int i = 6; i < 11; i++) {
        UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"image%d",i]]];
        image.frame = CGRectMake((i - 6 )* WIDTH, 0, WIDTH, HEIGHT);
        [self.scrollView addSubview:image];
        
        if (i == 10) {
            image.userInteractionEnabled = YES;
           
            
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
            [image addGestureRecognizer:tap];
           
            

            
        }
    }
    //按页滑动
    self.scrollView.pagingEnabled = YES;
    //隐藏水平滚动条
    self.scrollView.showsHorizontalScrollIndicator = NO;
    //关闭回弹效果
    self.scrollView.bounces = NO;
 
    

   
}






//对应手势方法
- (void)tapAction:(UITapGestureRecognizer *)tap
 {
   // RecommendViewController *recommendVC = [[RecommendViewController alloc]init];
     
     //self.tabBar = [[UITabBarController alloc]init];
     
     [self.navigationController pushViewController:self.tabBar animated:YES];
    
}







//******************************************************************************

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
//在这个方法里监听contentOffset内容偏移量
    NSLog(@"完成滚动");
    
    if ([scrollView isMemberOfClass:[UITableView class]]) {
        
    }else{
        int index = fabs(scrollView.contentOffset.x) / scrollView.frame.size.width; // 当前是第几个视图
        self.pageControl.currentPage = index;
    
    }
    
}

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{

    NSLog(@"将要开始拖动");
}

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    NSLog(@"结束拖动");

}

-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
    NSLog(@"滚动将要开始减速");

}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    NSLog(@"滚动减速到停止");

}

-(BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView{
    NSLog(@"是否滚动到顶部");
    return YES;

}

-(void)scrollViewDidScrollTop:(UIScrollView *)scrollView{

    NSLog(@"滚动到顶部");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
